#coding=UTF-8
import requests
import json

# 引入自定义的keystone模块
import keystone
keystone_s=keystone.getToken()

snapshots_url="http://192.168.100.10:8774/v2.1/os-snapshots"
headers={
    "X-Auth-Token":keystone_s['token']
}
body={
    "snapshot": {
        "display_name": "snap-001",
        "display_description": "Daily backup",
        "volume_id": "832ab0dc-97f4-4c0a-9b9b-201b92e122ae",
        "force": "false"
     }
}

req=requests.post(snapshots_url,headers=headers,data=json.dumps(body))
if req.status_code==200:
    print ("创建成功：")
print (json.dumps(req.json(),sort_keys=True,indent=4))